package com.atguigu.tingshu;

import com.atguigu.tingshu.common.constant.RedisConstant;
import com.atguigu.tingshu.search.service.SearchService;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.redisson.api.RBloomFilter;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

@Slf4j
@SpringBootTest
class ServiceSearchApplicationTest1 {

    @Autowired
    private SearchService searchService;


    @Autowired
    private RedissonClient redissonClient;


    /**
     * 不严谨批量导入
     */
    @Test
    public void batchImportData() {
        RBloomFilter<Long> bloomFilter = redissonClient.getBloomFilter(RedisConstant.ALBUM_BLOOM_FILTER);
        for (long i = 1; i < 1605; i++) {
            try {
                //searchService.upperAlbum(i);
                bloomFilter.add(i);
            } catch (Exception e) {
                log.error("导入异常：{}" + e);
                continue;
            }
        }
    }
}
